/****************************************************************************
	This file is part of Basqet.

	Basqet is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Basqet is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
    along with Basqet.  If not, see <http://www.gnu.org/licenses/>.

****************************************************************************/

#ifndef BASKETMANAGER_H
#define BASKETMANAGER_H

#include "basketcontent.h"
#include "commandmanager.h"
#include "uicapabilities.h"
#include "tagmanager.h"

#include <QObject>
#include <QPointer>
#include <QExplicitlySharedDataPointer>


/***************************************************************************/
// Predeclarations

class NotePadPage;
/***************************************************************************/
/// The main controller and manager for a loaded basket.
/** Is responsible for coordinating all activities around a basket. Owns
  * all invoulved object and is capabale of displaing the bakset content
  * in several views.
  * Also carries the basket content hieracy where data is maintained in
  * memory and at disk/database.
  */
class BasketManager : public QObject
{
	Q_OBJECT

	private:
		Q_DISABLE_COPY(BasketManager);

	public:
		/// Open or creates a basket on the give directory-location
		BasketManager(const QString& location);

		/// Populate the basket by reading existing content from disk.
		void openBasket();


		/// Creat a page view related to an existing page-widget.
		NotePadPage* getNotePadPage();

		/// Return a chared pointer to the commandManager.
		QExplicitlySharedDataPointer<CommandManager>	getCommandManager();


		QExplicitlySharedDataPointer<TagManager>		getTagManager();

		/// Check whether the basket is still avaliable on disk or if something is changed.
		bool verifyBasket();

	public slots:

		void actionSave();
		void actionPrintXML();

		void actionExportTo(QString fileName);

	signals:

		void activated(QObject *, UICapabilities capabilities);
		void deActivated(QObject *, UICapabilities capabilities);



	private:

		QString											mLocation;
		QExplicitlySharedDataPointer<BasketContent>		mBasketContent;
		QExplicitlySharedDataPointer<CommandManager>	mCommandManager;
		QExplicitlySharedDataPointer<TagManager>		mTagManager;

		QPointer<NotePadPage>							mCurrentNotePadPage;


};

#endif // BASKETMANAGER_H
